<template>
  <div class="page">
    <titleVue :title="'自动评价时间配置'"></titleVue>
    <div class="main">
      <el-form ref="form" :model="form" :rules="rules" label-width="200px">
        <el-form-item label="自动评价时间(天数)" prop="day">
          <el-input style="width: 220px;"  v-model="form.day"
            onkeyup="value=value.replace(/[^\d]/g,'')">
            <template slot="suffix">
              <div class="suffixText">天</div>
            </template>
          </el-input>
        </el-form-item>
      </el-form>
    </div>
    <div class="BtnBox">
      <button class="submitBtn" @click="saveEvent">保存</button>
    </div>
  </div>
</template>

<script>
import titleVue from '@/components/titleVue.vue'
import httpApi from '@/http'
export default {
  data() {
    return {
      form: {
        day: '',
      },
      rules: {
       
        day: [
          { required: true, message: '请填写自动评价时间(天)', trigger: 'blur' }
        ],
      },
      totalTime: '',
      cid:''

    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      let params = {}
      httpApi.basicSettingApi.getAutoEvaluation(params).then((res) => {
          this.cid=res.data.data.cid
          this.form.day=res.data.data.automaticTime
         
     
      });
    },
    saveEvent() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
      
         
          let params = {
            automaticTime: this.form.day,
            type: 2,
            cid:this.cid
          }
          httpApi.basicSettingApi.updateAutoEvaluation(params).then((res) => {
            if (res.data.code == 200) {
              this.$message.success('保存成功')
              this.getData
            }
          });
        } else {
          this.$message.error('请填写完整信息')
          return false;
        }
      });
    },
  },
  components: {
    titleVue
  }
}
</script>

<style lang="scss" scoped>
.page {
  height: 100vh;
  height: calc(100vh - 191px);
  padding: 30px;
  position: relative;
}

.main {
  background-color: #fff;

  .suffixText {
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 400;
    color: #CCCCCC;
    text-align: center;
    line-height: 40px;

    padding-right: 10px;
  }
}

.BtnBox {
  width: 100%;
  padding: 20px;
  display: flex;
  justify-content: center;
  position: absolute;
  bottom: 0;

  .submitBtn {
    cursor: pointer;
    height: 36px;
    border-radius: 4px;
    background-color: #1890FF;
    width: 80px;
    color: #fff;
    font-size: 12px;
    transition: 0.2s;

    &:hover {
      opacity: 0.8;
    }
  }
}
</style>